package io.netty.example.a;

import io.netty.buffer.UnpooledByteBufAllocator;

/**
 * @author: pch
 * @description:
 * @date: 2021/6/1
 **/
public class ByteBufTest {
	static int count = 10000;
	public static void main(String[] args) {
		unPoolDirect();

		unPool();
	}

	static void unPoolDirect(){
		long t = System.currentTimeMillis();
		for (int i = 0; i < count; i++) {
			UnpooledByteBufAllocator.DEFAULT.directBuffer(1024);
		}
		System.out.println(System.currentTimeMillis() - t);
	}

	static void unPool(){
		long t = System.currentTimeMillis();
		for (int i = 0; i < count; i++) {
			UnpooledByteBufAllocator.DEFAULT.heapBuffer(1024);
		}
		System.out.println(System.currentTimeMillis() - t);
	}
}